package com.eden.manage.controller;

import com.eden.manage.dto.common.DicDropDownDto;
import com.eden.manage.service.CommonService;
import eden.api.common.enums.AccountTypeEnum;
import eden.api.common.enums.CalTypeEnum;
import eden.api.common.enums.AgentLevelEnum;
import eden.api.common.enums.MemberLevelEnum;
import eden.api.common.model.EdenResult;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("common")
@RequiredArgsConstructor
public class CommonController {


    private final CommonService commonService;

    @GetMapping("user/type")
    public EdenResult<?> userTypeList(){
        return EdenResult.ok(commonService.getUserType());
    }
    @GetMapping("level")
    public EdenResult<?> levelList(){
        List<DicDropDownDto> list = new ArrayList<>();
        for (AgentLevelEnum value : AgentLevelEnum.values()) {
            list.add(new DicDropDownDto(value.getCode().toString(), value.getDescription()));
        }
        return EdenResult.ok(list);
    }
    @GetMapping("/member/level")
    public EdenResult<?> memberLevelList(){
        List<DicDropDownDto> list = new ArrayList<>();
        for (MemberLevelEnum value : MemberLevelEnum.values()) {
            list.add(new DicDropDownDto(value.getCode().toString(), value.getDescription()));
        }
        return EdenResult.ok(list);
    }

    @GetMapping("cal/type")
    public EdenResult<?> calTypes(){
        List<DicDropDownDto> list = new ArrayList<>();
        for (CalTypeEnum value : CalTypeEnum.values()) {
            list.add(new DicDropDownDto(value.name(), value.getDescription()));
        }
        return EdenResult.ok(list);
    }

    @GetMapping("acc/type")
    public EdenResult<?> accTypes(){
        List<DicDropDownDto> list = new ArrayList<>();
        for (AccountTypeEnum value : AccountTypeEnum.values()) {
            list.add(new DicDropDownDto(value.name(), value.getDescription()));
        }
        return EdenResult.ok(list);
    }


}
